package cn.itcast;


import cn.itcast.dao.KindDao;
import cn.itcast.dao.SaleInfoDao;
import cn.itcast.domain.Book;

import cn.itcast.domain.Kind;
import cn.itcast.domain.SaleInfo;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class Mybatis_test2 {
    public static void main(String[] args) throws IOException {
        InputStream in = Resources.getResourceAsStream("SqlMapConfig.xml");
        SqlSessionFactory build = new SqlSessionFactoryBuilder().build(in);
        SqlSession session = build.openSession();
        SaleInfoDao mapper = session.getMapper(SaleInfoDao.class);
        List<SaleInfo> all = mapper.findByDate();
        for (SaleInfo saleInfo : all) {
            System.out.println(saleInfo.getSdate());
            System.out.println(saleInfo.getNums());
            System.out.println(saleInfo.getBook().getCustomer().getName());

        }

    }

    }

